package gui.filefilter;

import enums.TextBundleEnum;
import enums.URLEnum;
import j_util.Utiles;
import misc.BundlesProvider;

import javax.swing.*;
import javax.swing.filechooser.FileView;
import java.io.File;
/*

    This file is part of Logica-Logike.

    Logica-Logike is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation version 3 of the License.

    Logica-Logike is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with Logica-Logike.  If not, see <http://www.gnu.org/licenses/>.

 */
/**
 * Extension de FileView, implementa metodos necesarios para ser usada como FileView
 * en archivos de extension .xml [Extended Markup Language];
 *
 * @author Jose Martin Rozanec;
 */
public class XMLFileView extends FileView {
    /**
     * Provee descripcion del tipo de archivo;
     *
     * @param file;
     * @return String descripcion;
     */
    public String getTypeDescription(File file) {
        String extension = Utiles.getExtension(file);
        String type = null;

        if (extension != null && extension.equals("xml")) {
            return BundlesProvider.getBundle(URLEnum.TEXT_BUNDLE).getString(TextBundleEnum.FILE.toString()) + " XML";
        }
        return type;
    }

    /**
     * Provee una imagen icono asociada al tipo de archivo;
     *
     * @param file;
     * @return Icon asociado al tipo de archivo;
     */
    public Icon getIcon(File file) {
        String extension = Utiles.getExtension(file);
        Icon icon = null;

        if (extension != null) {
            if (extension != null && extension.equals("xml")) {
                return Utiles.createImageIcon(URLEnum.XML_ICON.toString());
            }
        }
        return icon;
    }
}
